(function ($) {
	operModeSetup()
	function scoreTextTapped(){
		var textDom = this
		removeActive()
		var liDom = textDom.parentNode.parentNode
		currLiId = liDom.id
		liDom.classList.add('dhc-active')
		liDom.classList.add('text-active')
		opBoard.showDHCKeyboard();
		mui('#wrapper').scroll().reLayout();
		var index = parseInt(liDom.id)
		scrollToNewActiveScorLi(liDom);
		var score = paperData['SubItems'][index]['ItemScore']
		opBoard.updateDHCKeyboardUI(OperaMode,paperData['SubItems'][index]['CheckMenu'],score,function(newScore){
			var activeLi = mui('#scroll li.dhc-active')[0];
			if(!activeLi) {
				hideScoringPopover()
				return;
			}
			var rowIndex = parseInt(activeLi.id)
			activeLi.querySelector('.scoreText').innerText = newScore
			paperData['SubItems'][rowIndex]['ItemScore']=newScore
			choseNextScoreText()
			computeScore()
		});
	}
	
	function computeScore() {
		var items = paperData['SubItems']
		var realScore = 0;
		for(var i = 0; i < items.length; i++) {
			var itemDict = items[i];
			if(itemDict['HasChild'] == '1') {
				continue;
			}
			if (itemDict['ItemScore'] == '') {
				continue
			}
			realScore += parseFloat(itemDict['ItemScore'])
		}
		realScore = keepTwoDecimalPlaces(realScore); //--公共方法
		mui('#totalScore')[0].innerText = realScore+'分';
		checkScore = realScore
	}
	function operModeSetup(){
		mui('#scroll .scoreText').each(function (index,element) {
			element.addEventListener('tap',scoreTextTapped)
		})
		if (!opBoard ) {
			opBoard = new mui.DHCSelectBoard('scroll','',OperaMode,undefined,function(type,newScore) {
				var activeLi = mui('#scroll li.dhc-active')[0];
				if(!activeLi) {
					hideScoringPopover()
					return;
				}
				if (type == 'remark') {
					activeLi.classList.remove('dhc-active')
					mui.trigger(activeLi.querySelector('input'),'tap')
				}else if (type == 'last') {
					choseLastScoreText();	
				}else if (type == 'next') {
					choseNextScoreText();
				}else if (type == 'close') {
					hideScoringPopover();
					currLiId = ''
				}
			});	
			//opBoard.openDHCKeyboardDrag();
		}
	}
})(mui)